/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.lucava.boatskeeper.server.dao;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.lucava.boatskeeper.shared.dto.RoleDto;

/**
 *
 * @author glenn
 */
public class MockRoleDao {

    final static Map<Integer, RoleDto> roles = new HashMap<Integer, RoleDto>();

    static {
        for (int i = 0; i < 10; i++) {
            RoleDto r = new RoleDto();
            r.setId(i);
            r.setName("role" + i);
            roles.put(i, r);
        }
    }

    public static void add(RoleDto r) {
        r.setId(roles.size() - 1);
        roles.put(r.getId(), r);
    }

    public static void save(RoleDto r) {
        roles.get(r.getId()).setName(r.getName());
    }

    public static void delete(RoleDto r) {

        roles.remove(r.getId());
    }

    public static RoleDto get(Integer id) {
        return roles.get(id);
    }

    public static List<RoleDto> getAll() {

        return new ArrayList<RoleDto>(roles.values());
    }
}
